define(['plugins/router', 'knockout'], function(router, ko) {

	//childRouter以下方法可以链式调用，此处便于测试，分开写
	var childRouter = router.createChildRouter();
	childRouter.makeRelative({
		moduleId: 'app-ice/reactive-route',
		fromParent: true,
	});
	childRouter.map([
		{route: ['','apple'],moduleId: 'apple/index',title: 'apple',nav: true,hash:'#reactive-route/apple'},
		{route: 'banana',	 moduleId: 'banana/index',title: 'banana',nav: true,hash:'#reactive-route/banana'},
		{route: 'orange',moduleId: 'orange/index',title: 'orange',nav: true,hash:'#reactive-route/orange'}
	]);
	childRouter.buildNavigationModel();
	
	var currentRoutePath=ko.observable('#reactive-route/apple');
	var counter=ko.observable(0);
	var message=ko.observable('无');
	var timer=null;
	function activeRoute (routeInfo,event) {
		debugger;
		if(timer){
			clearTimeout(timer);
			message('撤销上一次的路由跳转');
		}
		
		childRouter.navigate(routeInfo.hash);
		return false;//阻止锚点默认行为
	}
	return {
		router: childRouter, //子路由也必须有此属性，原因和父级路由一致，原因是对data-bind="router: {}"此属性有特别处理
		currentRoutePath:currentRoutePath,
		counter:counter,
		message:message,
		activeRoute:activeRoute,
		activate:function(...rest){
			childRouter;
			if(rest[0]!==null){
				currentRoutePath(rest[0]);	
			}
			counter(counter.peek()+1);
		}
	}
})